export default [
    {
        path: "/",
        redirect: "/home", // 重定向
    },
    {
        path: "/home",
        name: "Home", // 首页
        component: () => import("@/pages/Home"),
    },
    {
        path: "/login",
        name: "Login", // 登录
        component: () => import("@/pages/Login"),
        meta: {
            isHidden: true, // 隐藏Footer组件
        },
    },
    {
        path: "/register",
        name: "Register", // 注册
        component: () => import("@/pages/Register"),
        meta: {
            isHidden: true, // 隐藏Footer组件
        },
    },
    {
        path: "/search/:searchKey?",
        name: "Search", // 搜索
        component: () => import("@/pages/Search"),
    },
    {
        path: "/details/:skuId",
        name: "Details", // 商品详情
        component: () => import("@/pages/Details"),
    },
    {
        path: "/addCartSuccess",
        name: "AddCartSuccess", // 添加购物车成功
        component: () => import("@/pages/AddCartSuccess"),
    },
    {
        path: "/shopCart",
        name: "ShopCart", // 购物车
        component: () => import("@/pages/ShopCart"),
    },
    {
        path: "/trade",
        name: "Trade", // 订单交易
        component: () => import("@/pages/Trade"),
        beforeEnter: (to, from, next) => {
            // 只能从购物车页面跳转到订单交易页面
            if (from.path === "/shopCart") {
                next();
            } else {
                next("/shopCart");
            }
        },
    },
    {
        path: "/pay",
        name: "Pay", // 支付
        component: () => import("@/pages/Pay"),
        beforeEnter: (to, from, next) => {
            // 只能从Trade跳转到Pay
            if (from.path === "/trade") {
                next();
            } else {
                next("/trade");
            }
        },
    },
    {
        path: "/paySuccess",
        name: "PaySuccess", // 支付成功
        component: () => import("@/pages/PaySuccess"),
        beforeEnter: (to, from, next) => {
            // 只能从Pay跳转到PaySuccess
            if (from.path === "/pay") {
                next();
            } else {
                next("/pay");
            }
        },
    },
    {
        path: "/center",
        // name: "Center", // 个人中心
        component: () => import("@/pages/Center"),
        redirect: "/center/myOrder",
        children: [
            {
                path: "myOrder",
                name: "MyOrder", // 我的订单
                component: () => import("@/pages/Center/components/MyOrder"),
            },
            {
                path: "groupOrder",
                name: "GroupOrder", // 团购订单
                component: () => import("@/pages/Center/components/GroupOrder"),
            },
        ],
    },
    {
        path: "/*",
        name: "404", // 404
        component: () => import("@/pages/NotFound"),
    },
];
